import { CountResult } from "@/apis/counts/type";

 export function sortByDate(arr: CountResult[]): CountResult[] {
    return arr.sort((a, b) => {
      const parseDate = (dateStr: string): Date => {
        const [month, day] = dateStr.split('月');
        const dayNum = parseInt(day.replace('日', ''));
        const monthNum = parseInt(month);
        return new Date(2023, monthNum - 1, dayNum); // 使用固定年份2023
      };
      
      const dateA = parseDate(a.label);
      const dateB = parseDate(b.label);
      
      return dateA.getTime() - dateB.getTime(); // 从小到大排序
    });
  }
  
